<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/11/15 0015
 * Time: 上午 8:55
 */
$all_data=array(
    1 => array('学PHP，冲击月薪10000+你也可以!','......'),
    2=>array('',''),
    3=>array('',''),
    4=>array('','')
);
$id=isset($_GET['id'])?intval($_GET['id']):1;
$id_prev=$id-1;
$id_next=$id+1;
if($id<1)$id=1;
if($id>4)$id=4;
if($id_prev<1)$id_prev=1;
if($id_next>4)$id_next=4;

if (isset($_COOKIE['history'])){
    $cookie_arr=explode(',',$_COOKIE['history'],4);
    foreach ($cookie_arr as $k=>$v){
        $cookie_arr[$k]=intval($cookie_arr[$k]);
        if($v ==$id) unset($cookie_arr[$k]);
    }
    if (count($cookie_arr)>3) array_shift($cookie_arr);
    $cookie_arr[]=$id;
    setcookie('history',implode(',',$cookie_arr));
}else{
    $cookie_arr=array($id);
    setcookie('history',$id);
}
$data=$all_data[$id];
$data_history=array();
foreach ($cookie_arr as $v){
    if (isset($all_data[$v])){
        $data_history[$v]=$all_data[$v][0];
    }
}

if (isset($_GET['action'])){
    if($_GET['action']=='clear'){
        $cookie_arr=array();
        setcookie('history','',time()-1);
    }
}

require ('article_html.php');








